/**
 * Created by yangyan on 2014/11/10 .
 * 操作日志
 */
Ext.define('manager.log', {
    extend:'Ext.grid.GridPanel',
    initComponent: function () {
        var fields = [ 'moduleName', 'ip', 'logContent', {
            name: "createdAt",
            type: 'date',
            dateFormat: 'time'
        },
            'createdByUserId', 'createdByRealName', 'returnSuccess', 'args', 'msgText', 'errorText' ];
        var columns = [
            {
                width:40,
                header: '结果',
                dataIndex: 'returnSuccess',
                renderer: function (v) {
                    if (v == 1) {
                        return '<img src="' + F.url('/resources/icons/16/accept.png') + '" />';
                    } else {
                        return '<img src="' + F.url('/resources/icons/16/cancel.png') + '" />';
                    }
                }
            },
            {
                header: '时间',
                dataIndex: 'createdAt',
                renderer: Ext.util.Format.dateRenderer("Y-m-d H:i:s"),
                width:140
            },
            {
                header: '姓名',
                dataIndex: 'createdByRealName'
            },
            {
                header: '模块',
                dataIndex: 'moduleName'
            },
            {
                header: '日志',
                dataIndex: 'logContent',
                flex: 1
            },
            {
                header: 'IP',
                dataIndex: 'ip'
            },


            {
                header: '返回信息',
                dataIndex: 'msgText'
            },
            {
                header: '返回错误',
                dataIndex: 'errorText'
            }
        ];
        var log_list_store = Ext.create('Ext.data.Store', {
            storeId: 'log_list_store',
            pageSize: 50,
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: F.url('/admin/log/list.do'),
                method: 'post',
                reader: {
                    type: 'json',
                    root: 'pageList.list',
                    idProperty: 'logId',
                    totalProperty: 'pageList.page.total',
                    messageProperty: "msg"
                }
            },
            fields: fields
        });

        Ext.apply(this, {
            dockedItems: [
                {
                    xtype: 'pagingtoolbar',
                    store: log_list_store,
                    dock: 'bottom',
                    displayInfo: true
                }
            ],
            store: log_list_store,
            columns: columns
        });

        this.callParent();
    }
});
